# $Id$
# Maintainer: Eric Belanger <eric@archlinux.org>
# Contributor: John Proctor <jproctor@prium.net>

pkgname=libxslt
pkgver=1.1.30
pkgrel=2
pkgdesc="XML stylesheet transformation library"
url="http://xmlsoft.org/XSLT/"
arch=(i686 x86_64)
license=(custom)
depends=(libxml2 libgcrypt)
makedepends=(python2 git)
checkdepends=(docbook-xml python)
_commit=bec1788d0627db0b510dcb337f989fae0440dbd5  # tags/v1.1.30^0
source=("git+https://git.gnome.org/browse/libxslt#commit=$_commit"
        0001-Fix-bashism-in-configure.in.patch
        0002-Set-XML_CONFIG-in-the-pkg-config-path.patch)
sha256sums=('SKIP'
            '2845fdea4c1191b9b61e0a8f27cb48b7489d525ef1dbb019eb2b9050f4d50f94'
            'bbc9eefc4fe3617554fffdc45838d9150d906a617719fa5eb59997f7deadd54b')

pkgver() {
  cd $pkgname
  git describe --tags | sed 's/^v//;s/-/+/g'
}

prepare() {
  cd $pkgname

  # https://bugzilla.gnome.org/show_bug.cgi?id=787617
  patch -Np1 -i ../0001-Fix-bashism-in-configure.in.patch
  patch -Np1 -i ../0002-Set-XML_CONFIG-in-the-pkg-config-path.patch

  sed -e 's|/usr/bin/python -u|/usr/bin/python2 -u|g' \
      -e 's|/usr/bin/python$|/usr/bin/python2|g' \
      -i python/tests/*.py

  NOCONFIGURE=1 ./autogen.sh
}

build() {
  cd $pkgname
  ./configure --prefix=/usr --with-python=/usr/bin/python2
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

check() {
  cd $pkgname
  make check
}

package() {
  cd $pkgname
  make DESTDIR="$pkgdir" install
  install -Dm644 COPYING "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
  find "$pkgdir" -name '*.a' -print -delete
}
